package com.remote.ui.core;

import com.remote.common.model.Response;
import com.remote.common.tool.MachineTool;
import io.netty.channel.ChannelHandlerContext;

public abstract class BaseControllerComponent implements ControllerComponent {

    private ControllerManager controllerManager;
    public MachineTool machineTool;

    public BaseControllerComponent() {
        this.machineTool = MachineTool.getInstance();
    }

    @Override
    public void onRead(ChannelHandlerContext ctx, Object obj) {
        Response response = (Response) obj;
        if (!response.getIsSucceed()) {
            return;
        }
        this.onRead0(ctx, response);
    }

    protected abstract void onRead0(ChannelHandlerContext ctx, Response response);

    @Override
    public void setControllerManager(ControllerManager controllerManager) {
        this.controllerManager = controllerManager;
    }

    @Override
    public ControllerManager getControllerManager() {
        return controllerManager;
    }
}
